
'''
status:
0:no body
1:have body 
2:game start
3:flod

gameStatus:
11:chip
12:nochip
'''

class seat:
	def __init__(self, id):
		self.seatid = id
		self.user = None 
		self.money = 0
		self.status = 0
		self.gameStatus = 0

		self.poker1 = -1
		self.poker1 = -2
		self.allChip = 0

	def isHaveUser(self):
		if self.user:
			return True
		return False

	def isInGame(self):
		if self.status == 2:
			return True
		return False


	def sit(self, user, sitMoney):
		if not user:
			return -1

		if self.user :
			return -2

		self.user = user
		self.money = sitMoney
		self.status = 1

	def stand(self):
		if not self.user:
			return -2
		self.user = None

	def systemChip(self, money):
		last = self.gameStatus
		self.gameStatus = 11
		self.chip(money, 2)
		self.gameStatus = last
		#print "seatid:%d, status:%d, system money :%d, allChip:%d" % (self.seatid, self.status, money, self.allChip)

	def chip(self, money, status):
		
		if self.status != 2 or self.gameStatus != 11:
			return 

		if status == 3: #flod
			self.status = 3

		if self.money < money:
			money = self.money

		self.money -= money
		self.allChip += money
		#print "seatid:%d, chipMoney:%d, allMoney:%d, selfMoney:%d, fun_status:%d" % (self.seatid, money, self.allChip, self.money, status)

	def start(self):
		self.status = 2

	def setHandle(self, poker1, poker2):
		self.poker1 = poker1
		self.poker2 = poker2
		print "seatid:%d, poker1:%x, poker2:%x" % (self.seatid, self.poker1, self.poker2)

	def setChipFlag(self):
		self.gameStatus = 11

	def setUnChipFlag(self):
		self.gameStatus = 12

